package demo1;

import javax.swing.plaf.synth.SynthUI;
import java.util.Objects;

public class Student implements Comparable<Student>,Cloneable{

    public String name;
    public int age;

    public Money m = new Money();



    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", m=" + m.money +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }


    @Override
    public int compareTo(Student o) {

        return this.name.compareTo(o.name);


        //年龄
        //return this.age - o.age;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {



        Student student = (Student) super.clone();

        student.m = (Money) this.m.clone();

        return student;
    }
}
